package com.wits.qso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import net.sf.json.JSONObject;

import com.wits.platform.entity.BaseEntity;

@Entity
@Table(name="qso_material_h")
public class MaterialH extends BaseEntity
{
	private String id = null;
	private Course couid = null;
	private String userId = null;
	
	public MaterialH() { super(); }
	
	@Id
	@GenericGenerator(name = "idGen", 
					strategy = "com.wits.platform.common.id.generator.IDGenerator",
					parameters={ 
								@Parameter(name="table_name",value="wits_id_generator"),
								@Parameter(name="value_column_name",value="gen_value"),
								@Parameter(name="segment_column_name",value="gen_name"),
								@Parameter(name="segment_value_length",value="5"),
								@Parameter(name="sq_format",value="%03d"), 
								@Parameter(name="sq_prefix",value="CL") 
					})
	@GeneratedValue(generator = "idGen")
	@Column(name = "mtrh_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	@Column(name="mtrh_userid", nullable = false, length = 10)
	public String getUserId() {
		return userId;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}
	
	@Override
    public String display() {
	    return null;
    }
	
	@ManyToOne
	@JoinColumn(name = "mtrh_couid")
	public Course getCouid() {
		return couid;
	}

	public void setCouid(Course couid) {
		this.couid = couid;
	}
	
	@Override
	public String toString(){
		return JSONObject.fromObject(this, MaterialH.getBaseJsonConfig()).toString();
	}
}
